package com.demo.springboot;

import org.springframework.context.event.ContextStoppedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
public class MyEventHandler {

    /***
     * @param event 参数任意，不能为空
     */
    @EventListener
    public void event(MyApplicationEvent event){
        System.out.println("MyEventHandler 接收到事件："+event.getClass());
    }

    @EventListener
    public void event2(ContextStoppedEvent event){
        System.out.println("应用停止 接收到事件："+event.getClass());
    }
}
